const pub = (function(){
	/**
	 * 控制页面缩放大小
	 * @param {Object} params
	 */
	const windowResize = function(params){
		let col = params
		let width = document.documentElement.clientWidth;
		if(width < 1300){
			col = {
				xs:20,
				offset:2
			}
		}else{
			col = {
				xs:8,
				offset:8
			}
		}
		
		return col
	}
	
	/**
	 * 对树装数据进行处理
	 * @param {Object} list
	 */
	const getTreeData = async function(list) {
		const treeData = [];
		const map = {};
		list.forEach((item)=>{
			map[item.cid] = item;
			// map[item.cid].value = item.cid;
		})
		list.forEach((item)=>{
			let parent = map[item.pid];
			if (parent) {
				if(!(parent.children instanceof Array)){
					parent.children = new Array()
				}
				parent.children.push(item)
				// (parent.children || (parent.children = [])).push(item);
			} else {
				treeData.push(item);
			}
		})
		return treeData
	}
	
	return {
		windowResize,
		getTreeData
	}
})();

export default pub